/**
 * Licensed to CMIM,Inc. under the terms of the CMIM * Software License version 1.0.
 * See the NOTICE file distributed with this work for additional * information regarding copyright ownership.
 * ---------------------------------------------------------------------------- * Date Author Version
 * 2019/3/16 neusoft 1.0
 **/

package com.xnyzc.lhy.task.task.driver;

import com.xnyzc.lhy.task.fegin.driver.QuartzDriverCashWithdrawalService;
import com.xnyzc.lhy.task.fegin.driver.QuartzDriverEarlyWarningService;
import com.xnyzc.lhy.task.fegin.driver.QuartzDriverWorkStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author: 刘举
 * @Date: 2019-07-27 11:16
 * @Description 司机工作统计相关
 */

@Slf4j
@Component("quartzDriverWorkStatistics")
public class QuartzDriverWorkStatistics {


    @Autowired
    private QuartzDriverWorkStatisticsService quartzDriverWorkStatisticsService;

    @Autowired
    private QuartzDriverCashWithdrawalService quartzDriverCashWithdrawalService;

    @Autowired
    private QuartzDriverEarlyWarningService quartzDriverEarlyWarningService;


    /**
     * 司机已接单或者前往预约地点订单的预警(每一分钟)
     */
    @Scheduled(cron = "0 */1 * * * ?")
    public void earlyWarning() {

        log.info("===========开始处理司机已接单或者前往预约地点订单的预警时长==========");
        quartzDriverEarlyWarningService.driverEarlyWarning();
        log.info("===========结束处理司机已接单或者前往预约地点订单的预警时长===========");

    }
    /**
     * 自动处理司机在线时长
     */
    @Scheduled(cron = "0 05 00 * * ?")
    public void updateOrdersData() {

        log.info("===========开始处理在线时长==========");
        quartzDriverWorkStatisticsService.updateOrdersData();
        log.info("===========结束处理在线时长===========");

    }


    /**
     * 监听司机活跃度
     */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void driverActiveListen() {
        log.info("==========开始监听司机活跃度==========");
        quartzDriverWorkStatisticsService.driverActiveListen();
        log.info("==========结束监听司机活跃度===========");
    }

    /**
     * 查询锁定的司机看看有无订单（每五分钟）
     */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void driverLockProtection() {

        log.info("===========开始锁定司机保护==========");
        quartzDriverWorkStatisticsService.driverLockProtection();
        log.info("===========结束锁定司机保护===========");

    }

    /**
     * 查看未支付订单-oa_d_order（每天晚上11点触发）
     */
    @Scheduled(cron = "0 0 23 * * ?")
    public void paymentReview() {

        log.info("===========开始复查未支付订单==========");
        quartzDriverWorkStatisticsService.paymentReview();
        log.info("===========结束复查未支付订单===========");

    }

    /**
     *
     */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void updateOrderStatus() {
        log.info("===========开始查询为应答的司机==========");
        quartzDriverWorkStatisticsService.updateOrderStatus();
        log.info("===========结束查询为应答的司机==========");
    }

    /**
     * 司机可提现次数刷新
     */
    @Scheduled(cron = "0 00 00 * * ?")
    public void clearCashWithdrawal() {

        log.info("===========司机可提现次数刷新=====o(∩_∩)o =====");
        quartzDriverCashWithdrawalService.clearDriverCashWithdrawal();
        log.info("===========司机可提现次数刷新完成=====o(∩_∩)o =====");

    }

    /**
     * 解冻司机余额
     */
    @Scheduled(cron = "0 00 00 * * ?")
    public void reFreezeBalance() {

        log.info("===========解冻司机余额==========");
        quartzDriverCashWithdrawalService.reFreezeBalance();
        log.info("===========司机余额解冻成功==========");

    }

    /**
     * 清除每月修改手机号限制
     */
    @Scheduled(cron = "0 0 0 1 * ?")
    public void reFlushUpdatePhoneCount() {

        log.info("===========清除每月修改手机号限制==========");
        quartzDriverWorkStatisticsService.reFushUpdatePhoneCount();
        log.info("===========清除成功===========");

    }

//    /**
//     * 调度订单
//     */
//    @Scheduled(cron = "0/5 * * * * ? ")
//    public void dispatchOrder() {
//        log.info("==========开始调度订单==========");
//        quartzDriverWorkStatisticsService.dispatchOrder();
//        log.info("==========结束调度订单===========");
//    }

}
